import { router } from "~/router"
import { getToken } from "~/composables/auth"
import { setStorage, getStorage, removeStorage } from '~/composables/storage'

import {
    toast,
    showFullLoading,
    hideFullLoading
} from "~/composables/util"
import store from "./store"
import { useUserStore } from '~/store/login'



// const AuthUrls = ['/home']
const AuthUrls = ['']
// 全局前置守卫
let hasGetInfo = false
router.beforeEach(async (to, from, next) => {
    // 显示loading
    showFullLoading()


    // 设置页面标题
    let title = (to.meta.title ? to.meta.title : "") + "工程运维可视化系统"
    document.title = title

    const userStore = useUserStore()
    const token = userStore.xiaoFang_token






    if (AuthUrls.includes(to.path)) {
        if (token) {
            next()
        } else {
            next('/')
        }
    } else {
        next()
    }
})

// 全局后置守卫
router.afterEach((to, from) => hideFullLoading())